import moment from 'moment'
export class DBObject {
    public id: string;
    public createDate?: number;
    public updateDate?: number;
    constructor(idLength: number) {
        this.id = this.genID();
        this.createDate = moment().valueOf();
        this.updateDate = moment().valueOf();
    }
    public update() {
        this.updateDate = moment().valueOf();
    }
    private genID() {
        let unix = moment().valueOf();
        let random = parseInt((Math.random() * 10000).toFixed(0), 10);
        let result = unix + random;
        return result.toString();
    }
}